package com.leo.entity;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;

/**
 * @Author: wangss
 * @CreateTime: 2023-05-31  15:00
 * @Description: 自定义实体
 */
public class CustomEntityFactory implements EntityFactory {

    @Spawns("rect,square")
    public Entity createRect(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                .view(new Rectangle(20, 20, Color.BLUE))
                .build();
    }

    @Spawns("circle")
    public Entity createCircle(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                .view(new Circle(spawnData.getX(), Color.DARKSLATEGREY))
                .build();
    }

    @Spawns("line")
    public Entity createLine(SpawnData spawnData) {
        return FXGL.entityBuilder(spawnData)
                .view(new Line())
                .build();
    }
}
